import java.util.*;

public class bb {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s = sc.nextLine();
        ListNode[] listNodes = get(s);
        ListNode res=new ListNode(0);
        ListNode dum=res;
        ListNode l1=listNodes[0];
        ListNode l2=listNodes[1];

        while(l1!=null&&l2!=null){
            if(l1.val<=l2.val){
                res.next=l1;
                l1=l1.next;
            }else{
                res.next=l2;
                l2=l2.next;
            }
            res=res.next;
        }
        res.next=l1==null?l2:l1;
        ListNode next = dum.next;
        while (next!=null){
            if (next.next==null){
                System.out.print(next.val);
            }else{
                System.out.print(next.val+",");
            }

            next=next.next;
        }

    }
    public static ListNode[] get(String s){
        String[] split = s.split("\\|");

        String[] split1 = split[0].split(",");
        String[] split2 = split[1].split(",");
        List<ListNode> list1=new ArrayList<>();
        List<ListNode> list2=new ArrayList<>();
        for (int i=0;i<split1.length;i++){
            int integer = Integer.valueOf(split1[i]);
            ListNode l=new ListNode(integer);
            list1.add(l);
        }
        for (int i=0;i<split2.length;i++){
            int integer = Integer.valueOf(split2[i]);
            ListNode l=new ListNode(integer);
            list2.add(l);
        }
        ListNode listNode1 = list1.get(0);
        ListNode listNode11 = listNode1;
        for (int i=1;i<list1.size();i++){
            listNode1.next=list1.get(i);
            listNode1=listNode1.next;
        }
        ListNode listNode2 = list2.get(0);
        ListNode listNode22 = listNode2;
        for (int i=1;i<list2.size();i++){
            listNode2.next=list2.get(i);
            listNode2=listNode2.next;
        }
        ListNode[] res=new ListNode[2];
        res[0]=listNode11;
        res[1]=listNode22;
        return res;
    }
    static class ListNode{
        int val;
        ListNode next;
        ListNode(int x){
            val=x;
        }
    }
    }



